package com.xy.order.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.order.vo.SubmitPictures;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.xy.order.service.ISubmitPicturesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 订单审核照片Controller
 *
 * @author ruoyi
 * @date 2025-07-05
 */
@RestController
@RequestMapping("/pictures")
public class SubmitPicturesController extends BaseController
{
    @Autowired
    private ISubmitPicturesService submitPicturesService;

    /**
     * 查询订单审核照片列表
     */
    @RequiresPermissions("order:pictures:list")
    @GetMapping("/list")
    public TableDataInfo list(SubmitPictures submitPictures)
    {
        startPage();
        List<SubmitPictures> list = submitPicturesService.selectSubmitPicturesList(submitPictures);
        return getDataTable(list);
    }


    /**
     * 根据订单编号查询订单审核照片列表
     */
//    @RequiresPermissions("order:pictures:list")
    @GetMapping("/listByOrderId")
    public TableDataInfo listByOrderId(SubmitPictures submitPictures)
    {
        startPage();
        List<SubmitPictures> list = submitPicturesService.selectSubmitPicturesByOrderId(submitPictures.getOrderId());
        return getDataTable(list);
    }


    /**
     * 导出订单审核照片列表
     */
    @RequiresPermissions("order:pictures:export")
    @Log(title = "订单审核照片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SubmitPictures submitPictures)
    {
        List<SubmitPictures> list = submitPicturesService.selectSubmitPicturesList(submitPictures);
        ExcelUtil<SubmitPictures> util = new ExcelUtil<SubmitPictures>(SubmitPictures.class);
        util.exportExcel(response, list, "订单审核照片数据");
    }

    /**
     * 获取订单审核照片详细信息
     */
    @RequiresPermissions("order:pictures:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(submitPicturesService.selectSubmitPicturesById(id));
    }

    /**
     * 新增订单审核照片
     */
    @RequiresPermissions("order:pictures:add")
    @Log(title = "订单审核照片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SubmitPictures submitPictures)
    {
        return toAjax(submitPicturesService.insertSubmitPictures(submitPictures));
    }

    /**
     * 修改订单审核照片
     */
    @RequiresPermissions("order:pictures:edit")
    @Log(title = "订单审核照片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SubmitPictures submitPictures)
    {
        return toAjax(submitPicturesService.updateSubmitPictures(submitPictures));
    }

    /**
     * 删除订单审核照片
     */
    @RequiresPermissions("order:pictures:remove")
    @Log(title = "订单审核照片", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(submitPicturesService.deleteSubmitPicturesByIds(ids));
    }
}

